﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace TYControl
{
    public class AutoDataGrid : DataGrid
    {
        public AutoDataGrid()
        {
            this.SizeChanged += AutoDataGrid_SizeChanged;
        }

        private void AutoDataGrid_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e)
        {
            if (this.Items.Count > 0)
            {
                RowHeight = (ActualHeight - ColumnHeaderHeight) / this.Items.Count;
            }
        }

        public void ResizeRowHeight()
        {
            if (this.Items.Count > 0)
            {
                RowHeight = (ActualHeight - ColumnHeaderHeight) / this.Items.Count;
            }
        }
    }
}
